uniform sampler2D colorMap;

void main(void)
{
	vec4 sum = vec4(0);
	vec2 texcoord = vec2(gl_TexCoord[0]);
	int j;
	int i;

	for(i = 0 ;i < 4; i++)
	{
		for (j = 0; j < 4; j++)
		{
			sum += texture2D(colorMap, texcoord + vec2(j,i)*0.004) * 0.55;
		}
	}
	if(texture2D(colorMap, texcoord).r < 0.3)
	{
		gl_FragColor = sum*sum*0.012 + texture2D(colorMap, texcoord);
	}
	else
	{
		if (texture2D(colorMap, texcoord).r < 0.5)
		{
			gl_FragColor = sum*sum*0.009 + texture2D(colorMap, texcoord);
		}
		else
		{
			gl_FragColor = sum*sum*0.0075 + texture2D(colorMap, texcoord);
		}
	}
}
